package cn.zlg.common.datadump.bean;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class BatchDeleteResult {
    private int total;
    private int success;
    private List<String> errors;

    private int code;
    private Object data;

    public void addError(String e) {
        if (errors == null) {
            errors = new ArrayList<>();
        }
        errors.add(e);
    }

    public static BatchDeleteResult empty() {
        BatchDeleteResult r = new BatchDeleteResult();
        r.setTotal(0);
        r.setSuccess(0);
        return r;
    }
    public static BatchDeleteResult create(int total, int success) {
        return success < 0 ? null : create(total, success, null);
    }
    public static BatchDeleteResult create(int total, int success, List<String > errors) {
        BatchDeleteResult r = new BatchDeleteResult();
        r.setTotal(total);
        r.setSuccess(success);
        r.setErrors(errors);
        return r;
    }
}
